package utils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Set;

public class StopWords {
    private Set<String> stopWords;

    public StopWords(String filePath) throws IOException {
        this.stopWords = new HashSet<>();
        loadStopWords(filePath);
    }

    private void loadStopWords(String filePath) throws IOException {
        Files.lines(Paths.get(filePath))
                .map(String::trim)
                .filter(line -> !line.isEmpty())
                .forEach(stopWords::add);
    }

    public boolean isStopWord(String word) {
        return stopWords.contains(word.toLowerCase());
    }
}